

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

static void printStr(char*);

int main(int agrc,char *argv[]){

    __pid_t pid;

    if ((pid = fork()) < 0)
    {
        printf("fork error!\n");
        exit(1);
    }

    if (pid == 0)
    {
        // child
        printStr("output from child!\n");
    }else{
        // parent
        printStr("output from parent!\n");
    }
    return 0;
}


static void printStr(char* str){
    char *ptr;
    int c = 0;
    setbuf(stdout,NULL);  // unbuffered
    for (ptr = str; *ptr != 0;ptr++){
        putc(*ptr,stdout);
    }
}